import type { Module, ActionContext } from 'vuex'
import type { AxiosResponse } from 'axios'
import {
  getRoadManageList,
  addRoadManageInfo,
  updateRoadManageInfo,
  deleteRoadManageInfo,
  importRoadManageInfo,
  relevenceDevInfo,
  roadInfo
} from '~/api/assetManagement/roadManage/roadManage'
// import { getDataDictionaryByCode } from '~/api/global'
// import { DownloadAttachment } from '~/utils/util'

const roadManage: Module<Record<string, any>, Record<string, any>> = {
  namespaced: true,
  actions: {
    // 获取道路分组列表
    async GetRoadManageList<S, T>(_: ActionContext<S, T>, params: T) {
      return await getRoadManageList<T>(params).then((res: AxiosResponse) => res?.data)
    },
    // 添加道路分组项基础资料
    async AddRoadManageInfo<S, T>(_: ActionContext<S, T>, params: T) {
      return await addRoadManageInfo<T>(params).then((res: AxiosResponse) => res?.data)
    },
    // 修改道路分组项基础资料
    async UpdateRoadManageInfo<S, T>(_: ActionContext<S, T>, params: T) {
      return await updateRoadManageInfo<T>(params).then((res: AxiosResponse) => res?.data)
    },
    // 删除道路项
    async DeleteRoadManageInfo<S, T>(_: ActionContext<S, T>, params: T) {
      return await deleteRoadManageInfo<T>(params).then((res: AxiosResponse) => res?.data)
    },
    // 道路管理导入文件
    async ImportRoadManageInfo<S, T>(_: ActionContext<S, T>, params: T) {
      return await importRoadManageInfo<T>(params).then((res: AxiosResponse) => res?.data)
    },
    // 道路关联设施
    async RelevenceDevInfo<S, T>(_: ActionContext<S, T>, params: T) {
      return await relevenceDevInfo<T>(params).then((res: AxiosResponse) => res?.data)
    },
    // 详情
    async RoadInfo<S, T>(_: ActionContext<S, T>, params: T) {
      return await roadInfo<T>(params).then((res: AxiosResponse) => res?.data)
    }
  }
}

export default roadManage
